home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / djgpp / libsrc / c / io / scanf.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-07-17  |  897 b   |  48 lines

  1. /* This is file SCANF.C */
  2. /* This file may have been modified by DJ Delorie (Jan 1991).  If so,
  3. ** these modifications are Coyright (C) 1993 DJ Delorie, 24 Kirsten Ave,
  4. ** Rochester NH, 03867-2954, USA.
  5. */
  6.  
  7. #include <stdio.h>
  8. #include <stdarg.h>
  9.  
  10. scanf(const char *fmt, ...)
  11. {
  12.   int r;
  13.   va_list a;
  14.   va_start(a, fmt);
  15.   r = _doscan(stdin, fmt, a);
  16.   va_end(a);
  17.   return r;
  18. }
  19.  
  20. fscanf(FILE *iop, const char *fmt, ...)
  21. {
  22.   int r;
  23.   va_list a;
  24.   va_start(a, fmt);
  25.   r = _doscan(iop, fmt, a);
  26.   va_end(a);
  27.   return r;
  28. }
  29.  
  30. sscanf(const char *str, const char *fmt, ...)
  31. {
  32.   int r;
  33.   va_list a;
  34.   FILE _strbuf;
  35.  
  36.   va_start(a, fmt);
  37.  
  38.   _strbuf._flag = _IOREAD|_IOSTRG;
  39.   _strbuf._ptr = _strbuf._base = str;
  40.   _strbuf._cnt = 0;
  41.   while (*str++)
  42.     _strbuf._cnt++;
  43.   _strbuf._bufsiz = _strbuf._cnt;
  44.   r = _doscan(&_strbuf, fmt, a);
  45.   va_end(a);
  46.   return r;
  47. }
  48.